package com.huawei.appgallery.forum.section.fragment;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.huawei.appgallery.forum.base.ui.JGWTabFragment;
import com.huawei.appgallery.forum.section.api.ISectionTabFragmentProtocol;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSStyleSheet;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.Layout;
import com.huawei.hmf.annotation.FragmentDefine;
import java.util.List;
import o.bqx;
import o.bri;
import o.bsl;
import o.bsv;
import o.cab.c;
import o.cax;
import o.cia;
import o.cip;
import o.cix;
import o.fjm;
import org.json.JSONObject;

@FragmentDefine(alias = "ForumSectionTabFragment", protocol = ISectionTabFragmentProtocol.class)
public class ForumSectionTabFragment extends JGWTabFragment implements cix {
    private fjm ﾞ = fjm.ॱ(this);

    public void ˏ(Bundle bundle) {
        ISectionTabFragmentProtocol iSectionTabFragmentProtocol = (ISectionTabFragmentProtocol) this.ﾞ.ॱ();
        this.ॱꜟ = iSectionTabFragmentProtocol.getSupportNetworkCache();
        this.ʼˊ = iSectionTabFragmentProtocol.getUri();
        ˎ(iSectionTabFragmentProtocol.getTabStyle());
        this.ʼᐝ = iSectionTabFragmentProtocol.getFragmentID();
        this.ͺˏ = iSectionTabFragmentProtocol.getStyle();
        this.ˎͺ = iSectionTabFragmentProtocol.getCss();
        this.ˋʻ = iSectionTabFragmentProtocol.getCssSelector();
        this.ʼ = new bsl(this, iSectionTabFragmentProtocol.getAppId(), this.ʼˊ, bsv.ॱ(iSectionTabFragmentProtocol.getDomainId()));
        super.ˏ(bundle);
    }

    public View ˋ(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View ˋ = super.ˋ(layoutInflater, viewGroup, bundle);
        if (this.ͺˎ != null) {
            this.ͺˎ.setBlankViewHeight(ᐝॱ().getDimensionPixelOffset(c.ʻ));
            this.ͺˎ.setFooterViewListener(this);
            if (this.ͺˎ.ˊॱ() != null) {
                ˊ(this.ͺˎ.ˊॱ());
            }
        }
        return ˋ;
    }

    public void ʽ(String str) {
        this.ʼˊ = str;
        if (this.ʼ instanceof bsl) {
            this.ʼ.ॱ(str);
        }
    }

    public void ˎͺ() {
        super.ˎͺ();
    }

    public cia ˊ(Context context) {
        boolean z = false;
        if (this.ʼˊ != null) {
            z = this.ʼˊ.contains("forum|forum_detail_all");
        }
        return new cax(context, z);
    }

    public cia ॱˉ() {
        return this.י;
    }

    public void ˏॱ(int i) {
        if (this.ͺˎ != null) {
            this.ͺˎ.setSelection(i);
        }
    }

    public void ॱˑ() {
        super.ˋॱ(true);
    }

    public void ॱʾ() {
        if (this.ͺˎ != null) {
            this.ͺˎ.ॱˎ();
        }
    }

    public void ॱـ() {
        if (this.ͺˎ != null) {
            this.ͺˎ.ͺ();
        }
    }

    public void ˊ(bri o_bri, BaseDetailResponse baseDetailResponse) {
        super.ˊ(o_bri, baseDetailResponse);
        if (!TextUtils.isEmpty(this.ˎͺ)) {
            try {
                baseDetailResponse.ˏ(new JSONObject(this.ˎͺ));
                List ʻॱ = baseDetailResponse.ʻॱ();
                int size = ʻॱ.size();
                for (int i = 0; i < size; i++) {
                    ((Layout) ʻॱ.get(i)).ॱ(this.ˋʻ);
                }
            } catch (Throwable e) {
                bqx.ˊ("ForumSectionTabFragment", "Exception", e);
            }
        }
    }

    public void ॱˍ() {
        if (this.ॱˌ != null && this.ͺˏ == 1 && (this.ॱˌ instanceof cip)) {
            ˊ(((cip) this.ॱˌ).ॱ());
        }
    }

    private void ˊ(View view) {
        if (this.ˎͺ != null && this.ˋʻ != null && view != null) {
            CSSSelector cSSSelector = new CSSSelector(this.ˋʻ);
            CSSStyleSheet parse = CSSStyleSheet.parse(this.ˎͺ);
            if (parse != null) {
                CSSRule rule = cSSSelector.getRule(parse.getRootRule());
                if (rule != null) {
                    CSSView.wrap(view, rule).render();
                }
            }
        }
    }

    public void ͺˏ() {
        super.ͺˏ();
        if (this.ߴ != null && this.ͺˏ == 1) {
            ˊ(this.ߴ);
        }
    }

    public String ॱˌ() {
        return ॱᶥ();
    }
}
